home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2000 March / maximum-cd-2000-03.iso / Quake3 Game Source / Q3AGameSource.exe / Main / g_local.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-18  |  30.1 KB  |  859 lines

  1. // Copyright (C) 1999-2000 Id Software, Inc.
  2. //
  3. // g_local.h -- local definitions for game module
  4.  
  5. #include "q_shared.h"
  6. #include "bg_public.h"
  7. #include "g_public.h"
  8.  
  9. //==================================================================
  10.  
  11. // the "gameversion" client command will print this plus compile date
  12. #define    GAMEVERSION    "baseq3"
  13.  
  14. #define BODY_QUEUE_SIZE        8
  15.  
  16. #define INFINITE            1000000
  17.  
  18. #define    FRAMETIME            100                    // msec
  19. #define    EVENT_VALID_MSEC    300
  20. #define    CARNAGE_REWARD_TIME    3000
  21. #define REWARD_SPRITE_TIME    2000
  22.  
  23. #define    INTERMISSION_DELAY_TIME    1000
  24.  
  25. // gentity->flags
  26. #define    FL_GODMODE                0x00000010
  27. #define    FL_NOTARGET                0x00000020
  28. #define    FL_TEAMSLAVE            0x00000400    // not the first on the team
  29. #define FL_NO_KNOCKBACK            0x00000800
  30. #define FL_DROPPED_ITEM            0x00001000
  31. #define FL_NO_BOTS                0x00002000    // spawn point not for bot use
  32. #define FL_NO_HUMANS            0x00004000    // spawn point just for bots
  33.  
  34. // movers are things like doors, plats, buttons, etc
  35. typedef enum {
  36.     MOVER_POS1,
  37.     MOVER_POS2,
  38.     MOVER_1TO2,
  39.     MOVER_2TO1
  40. } moverState_t;
  41.  
  42. #define SP_PODIUM_MODEL        "models/mapobjects/podium/podium4.md3"
  43.  
  44. //============================================================================
  45.  
  46. typedef struct gentity_s gentity_t;
  47. typedef struct gclient_s gclient_t;
  48.  
  49. struct gentity_s {
  50.     entityState_t    s;                // communicated by server to clients
  51.     entityShared_t    r;                // shared by both the server system and game
  52.  
  53.     // DO NOT MODIFY ANYTHING ABOVE THIS, THE SERVER
  54.     // EXPECTS THE FIELDS IN THAT ORDER!
  55.     //================================
  56.  
  57.     struct gclient_s    *client;            // NULL if not a client
  58.  
  59.     qboolean    inuse;
  60.  
  61.     char        *classname;            // set in QuakeEd
  62.     int            spawnflags;            // set in QuakeEd
  63.  
  64.     qboolean    neverFree;            // if true, FreeEntity will only unlink
  65.                                     // bodyque uses this
  66.  
  67.     int            flags;                // FL_* variables
  68.  
  69.     char        *model;
  70.     char        *model2;
  71.     int            freetime;            // level.time when the object was freed
  72.     
  73.     int            eventTime;            // events will be cleared EVENT_VALID_MSEC after set
  74.     qboolean    freeAfterEvent;
  75.     qboolean    unlinkAfterEvent;
  76.  
  77.     qboolean    physicsObject;        // if true, it can be pushed by movers and fall off edges
  78.                                     // all game items are physicsObjects, 
  79.     float        physicsBounce;        // 1.0 = continuous bounce, 0.0 = no bounce
  80.     int            clipmask;            // brushes with this content value will be collided against
  81.                                     // when moving.  items and corpses do not collide against
  82.                                     // players, for instance
  83.  
  84.     // movers
  85.     moverState_t moverState;
  86.     int            soundPos1;
  87.     int            sound1to2;
  88.     int            sound2to1;
  89.     int            soundPos2;
  90.     int            soundLoop;
  91.     gentity_t    *parent;
  92.     gentity_t    *nextTrain;
  93.     gentity_t    *prevTrain;
  94.     vec3_t        pos1, pos2;
  95.  
  96.     char        *message;
  97.  
  98.     int            timestamp;        // body queue sinking, etc
  99.  
  100.     float        angle;            // set in editor, -1 = up, -2 = down
  101.     char        *target;
  102.     char        *targetname;
  103.     char        *team;
  104.     gentity_t    *target_ent;
  105.  
  106.     float        speed;
  107.     vec3_t        movedir;
  108.  
  109.     int            nextthink;
  110.     void        (*think)(gentity_t *self);
  111.     void        (*reached)(gentity_t *self);    // movers call this when hitting endpoint
  112.     void        (*blocked)(gentity_t *self, gentity_t *other);
  113.     void        (*touch)(gentity_t *self, gentity_t *other, trace_t *trace);
  114.     void        (*use)(gentity_t *self, gentity_t *other, gentity_t *activator);
  115.     void        (*pain)(gentity_t *self, gentity_t *attacker, int damage);
  116.     void        (*die)(gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod);
  117.  
  118.     int            pain_debounce_time;
  119.     int            fly_sound_debounce_time;    // wind tunnel
  120.     int            last_move_time;
  121.  
  122.     int            health;
  123.  
  124.     qboolean    takedamage;
  125.  
  126.     int            damage;
  127.     int            splashDamage;    // quad will increase this without increasing radius
  128.     int            splashRadius;
  129.     int            methodOfDeath;
  130.     int            splashMethodOfDeath;
  131.  
  132.     int            count;
  133.  
  134.     gentity_t    *chain;
  135.     gentity_t    *enemy;
  136.     gentity_t    *activator;
  137.     gentity_t    *teamchain;        // next entity in team
  138.     gentity_t    *teammaster;    // master of the team
  139.  
  140.     int            watertype;
  141.     int            waterlevel;
  142.  
  143.     int            noise_index;
  144.  
  145.     // timing variables
  146.     float        wait;
  147.     float        random;
  148.  
  149.     gitem_t        *item;            // for bonus items
  150.  
  151.     qboolean    botDelayBegin;
  152. };
  153.  
  154.  
  155. typedef enum {
  156.     CON_DISCONNECTED,
  157.     CON_CONNECTING,
  158.     CON_CONNECTED
  159. } clientConnected_t;
  160.  
  161. typedef enum {
  162.     SPECTATOR_NOT,
  163.     SPECTATOR_FREE,
  164.     SPECTATOR_FOLLOW,
  165.     SPECTATOR_SCOREBOARD
  166. } spectatorState_t;
  167.  
  168. typedef enum {
  169.     TEAM_BEGIN,        // Beginning a team game, spawn at base
  170.     TEAM_ACTIVE        // Now actively playing
  171. } playerTeamStateState_t;
  172.  
  173. typedef struct {
  174.     playerTeamStateState_t    state;
  175.  
  176.     int            location;
  177.  
  178.     int            captures;
  179.     int            basedefense;
  180.     int            carrierdefense;
  181.     int            flagrecovery;
  182.     int            fragcarrier;
  183.     int            assists;
  184.  
  185.     float        lasthurtcarrier;
  186.     float        lastreturnedflag;
  187.     float        flagsince;
  188.     float        lastfraggedcarrier;
  189. } playerTeamState_t;
  190.  
  191. // the auto following clients don't follow a specific client
  192. // number, but instead follow the first two active players
  193. #define    FOLLOW_ACTIVE1    -1
  194. #define    FOLLOW_ACTIVE2    -2
  195.  
  196. // client data that stays across multiple levels or tournament restarts
  197. // this is achieved by writing all the data to cvar strings at game shutdown
  198. // time and reading them back at connection time.  Anything added here
  199. // MUST be dealt with in G_InitSessionData() / G_ReadSessionData() / G_WriteSessionData()
  200. typedef struct {
  201.     team_t        sessionTeam;
  202.     int            spectatorTime;        // for determining next-in-line to play
  203.     spectatorState_t    spectatorState;
  204.     int            spectatorClient;    // for chasecam and follow mode
  205.     int            wins, losses;        // tournament stats
  206. } clientSession_t;
  207.  
  208. #define    MAX_VOTE_COUNT        3
  209.  
  210. // client data that stays across multiple respawns, but is cleared
  211. // on each level change or team change at ClientBegin()
  212. typedef struct {
  213.     clientConnected_t    connected;    
  214.     usercmd_t    cmd;                // we would lose angles if not persistant
  215.     qboolean    localClient;        // true if "ip" info key is "localhost"
  216.     qboolean    initialSpawn;        // the first spawn should be at a cool location
  217.     qboolean    predictItemPickup;    // based on cg_predictItems userinfo
  218.     char        netname[36];
  219.     int            maxHealth;            // for handicapping
  220.     int            enterTime;            // level.time the client entered the game
  221.     playerTeamState_t teamState;    // status in teamplay games
  222.     int            voteCount;            // to prevent people from constantly calling votes
  223.     qboolean    teamInfo;            // send team overlay updates?
  224. } clientPersistant_t;
  225.  
  226.  
  227. // this structure is cleared on each ClientSpawn(),
  228. // except for 'client->pers' and 'client->sess'
  229. struct gclient_s {
  230.     // ps MUST be the first element, because the server expects it
  231.     playerState_t    ps;                // communicated by server to clients
  232.  
  233.     // the rest of the structure is private to game
  234.     clientPersistant_t    pers;
  235.     clientSession_t        sess;
  236.  
  237.     qboolean    readyToExit;        // wishes to leave the intermission
  238.  
  239.     qboolean    noclip;
  240.  
  241.     int            lastCmdTime;        // level.time of last usercmd_t, for EF_CONNECTION
  242.                                     // we can't just use pers.lastCommand.time, because
  243.                                     // of the g_sycronousclients case
  244.     int            buttons;
  245.     int            oldbuttons;
  246.     int            latched_buttons;
  247.  
  248.     // sum up damage over an entire frame, so
  249.     // shotgun blasts give a single big kick
  250.     int            damage_armor;        // damage absorbed by armor
  251.     int            damage_blood;        // damage taken out of health
  252.     int            damage_knockback;    // impact damage
  253.     vec3_t        damage_from;        // origin for vector calculation
  254.     qboolean    damage_fromWorld;    // if true, don't use the damage_from vector
  255.  
  256.     int            accurateCount;        // for "impressive" reward sound
  257.  
  258.     //
  259.     int            lasthurt_client;    // last client that damaged this client
  260.     int            lasthurt_mod;        // type of damage the client did
  261.  
  262.     // timers
  263.     int            respawnTime;        // can respawn when time > this, force after g_forcerespwan
  264.     int            inactivityTime;        // kick players when time > this
  265.     qboolean    inactivityWarning;    // qtrue if the five seoond warning has been given
  266.     int            rewardTime;            // clear the EF_AWARD_IMPRESSIVE, etc when time > this
  267.  
  268.     int            airOutTime;
  269.  
  270.     int            lastKillTime;        // for multiple kill rewards
  271.  
  272.     qboolean    fireHeld;            // used for hook
  273.     gentity_t    *hook;                // grapple hook if out
  274.  
  275.     // timeResidual is used to handle events that happen every second
  276.     // like health / armor countdowns and regeneration
  277.     int            timeResidual;
  278. };
  279.  
  280.  
  281. //
  282. // this structure is cleared as each map is entered
  283. //
  284. #define    MAX_SPAWN_VARS            64
  285. #define    MAX_SPAWN_VARS_CHARS    2048
  286.  
  287. typedef struct {
  288.     struct gclient_s    *clients;        // [maxclients]
  289.  
  290.     struct gentity_s    *gentities;
  291.     int            gentitySize;
  292.     int            num_entities;        // current number, <= MAX_GENTITIES
  293.  
  294.     int            warmupTime;            // restart match at this time
  295.  
  296.     fileHandle_t    logFile;
  297.  
  298.     // store latched cvars here that we want to get at often
  299.     int            maxclients;
  300.  
  301.     int            framenum;
  302.     int            time;                    // in msec
  303.     int            previousTime;            // so movers can back up when blocked
  304.  
  305.     int            startTime;                // level.time the map was started
  306.  
  307.     int            teamScores[TEAM_NUM_TEAMS];
  308.     int            lastTeamLocationTime;        // last time of client team location update
  309.  
  310.     qboolean    newSession;                // don't use any old session data, because
  311.                                         // we changed gametype
  312.  
  313.     qboolean    restarted;                // waiting for a map_restart to fire
  314.  
  315.     int            numConnectedClients;
  316.     int            numNonSpectatorClients;    // includes connecting clients
  317.     int            numPlayingClients;        // connected, non-spectators
  318.     int            sortedClients[MAX_CLIENTS];        // sorted by score
  319.     int            follow1, follow2;        // clientNums for auto-follow spectators
  320.  
  321.     int            snd_fry;                // sound index for standing in lava
  322.  
  323.     int            warmupModificationCount;    // for detecting if g_warmup is changed
  324.  
  325.     // voting state
  326.     char        voteString[MAX_STRING_CHARS];
  327.     int            voteTime;                // level.time vote was called
  328.     int            voteYes;
  329.     int            voteNo;
  330.     int            numVotingClients;        // set by CalculateRanks
  331.  
  332.     // spawn variables
  333.     qboolean    spawning;                // the G_Spawn*() functions are valid
  334.     int            numSpawnVars;
  335.     char        *spawnVars[MAX_SPAWN_VARS][2];    // key / value pairs
  336.     int            numSpawnVarChars;
  337.     char        spawnVarChars[MAX_SPAWN_VARS_CHARS];
  338.  
  339.     // intermission state
  340.     int            intermissionQueued;        // intermission was qualified, but
  341.                                         // wait INTERMISSION_DELAY_TIME before
  342.                                         // actually going there so the last
  343.                                         // frag can be watched.  Disable future
  344.                                         // kills during this delay
  345.     int            intermissiontime;        // time the intermission was started
  346.     char        *changemap;
  347.     qboolean    readyToExit;            // at least one client wants to exit
  348.     int            exitTime;
  349.     vec3_t        intermission_origin;    // also used for spectator spawns
  350.     vec3_t        intermission_angle;
  351.  
  352.     qboolean    locationLinked;            // target_locations get linked
  353.     gentity_t    *locationHead;            // head of the location list
  354.     int            bodyQueIndex;            // dead bodies
  355.     gentity_t    *bodyQue[BODY_QUEUE_SIZE];
  356. } level_locals_t;
  357.  
  358.  
  359. //
  360. // g_spawn.c
  361. //
  362. qboolean    G_SpawnString( const char *key, const char *defaultString, char **out );
  363. // spawn string returns a temporary reference, you must CopyString() if you want to keep it
  364. qboolean    G_SpawnFloat( const char *key, const char *defaultString, float *out );
  365. qboolean    G_SpawnInt( const char *key, const char *defaultString, int *out );
  366. qboolean    G_SpawnVector( const char *key, const char *defaultString, float *out );
  367. void        G_SpawnEntitiesFromString( void );
  368. char *G_NewString( const char *string );
  369.  
  370. //
  371. // g_cmds.c
  372. //
  373. void Cmd_Score_f (gentity_t *ent);
  374. void StopFollowing( gentity_t *ent );
  375. void BroadcastTeamChange( gclient_t *client, int oldTeam );
  376. void SetTeam( gentity_t *ent, char *s );
  377. void Cmd_FollowCycle_f( gentity_t *ent, int dir );
  378.  
  379. //
  380. // g_items.c
  381. //
  382. void G_CheckTeamItems( void );
  383. void G_RunItem( gentity_t *ent );
  384. void RespawnItem( gentity_t *ent );
  385.  
  386. void UseHoldableItem( gentity_t *ent );
  387. void PrecacheItem (gitem_t *it);
  388. gentity_t *Drop_Item( gentity_t *ent, gitem_t *item, float angle );
  389. void SetRespawn (gentity_t *ent, float delay);
  390. void G_SpawnItem (gentity_t *ent, gitem_t *item);
  391. void FinishSpawningItem( gentity_t *ent );
  392. void Think_Weapon (gentity_t *ent);
  393. int ArmorIndex (gentity_t *ent);
  394. void    Add_Ammo (gentity_t *ent, int weapon, int count);
  395. void Touch_Item (gentity_t *ent, gentity_t *other, trace_t *trace);
  396.  
  397. void ClearRegisteredItems( void );
  398. void RegisterItem( gitem_t *item );
  399. void SaveRegisteredItems( void );
  400.  
  401. //
  402. // g_utils.c
  403. //
  404. int G_ModelIndex( char *name );
  405. int        G_SoundIndex( char *name );
  406. void    G_TeamCommand( team_t team, char *cmd );
  407. void    G_KillBox (gentity_t *ent);
  408. gentity_t *G_Find (gentity_t *from, int fieldofs, const char *match);
  409. gentity_t *G_PickTarget (char *targetname);
  410. void    G_UseTargets (gentity_t *ent, gentity_t *activator);
  411. void    G_SetMovedir ( vec3_t angles, vec3_t movedir);
  412.  
  413. void    G_InitGentity( gentity_t *e );
  414. gentity_t    *G_Spawn (void);
  415. gentity_t *G_TempEntity( vec3_t origin, int event );
  416. void    G_Sound( gentity_t *ent, int channel, int soundIndex );
  417. void    G_FreeEntity( gentity_t *e );
  418.  
  419. void    G_TouchTriggers (gentity_t *ent);
  420. void    G_TouchSolids (gentity_t *ent);
  421.  
  422. float    *tv (float x, float y, float z);
  423. char    *vtos( const vec3_t v );
  424.  
  425. float vectoyaw( const vec3_t vec );
  426.  
  427. void G_AddPredictableEvent( gentity_t *ent, int event, int eventParm );
  428. void G_AddEvent( gentity_t *ent, int event, int eventParm );
  429. void G_SetOrigin( gentity_t *ent, vec3_t origin );
  430.  
  431. //
  432. // g_combat.c
  433. //
  434. qboolean CanDamage (gentity_t *targ, vec3_t origin);
  435. void G_Damage (gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, vec3_t dir, vec3_t point, int damage, int dflags, int mod);
  436. qboolean G_RadiusDamage (vec3_t origin, gentity_t *attacker, float damage, float radius, gentity_t *ignore, int mod);
  437. void body_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath );
  438. void TossClientItems( gentity_t *self );
  439.  
  440. // damage flags
  441. #define DAMAGE_RADIUS            0x00000001    // damage was indirect
  442. #define DAMAGE_NO_ARMOR            0x00000002    // armour does not protect from this damage
  443. #define DAMAGE_NO_KNOCKBACK        0x00000008    // do not affect velocity, just view angles
  444. #define DAMAGE_NO_PROTECTION    0x00000020  // armor, shields, invulnerability, and godmode have no effect
  445.  
  446. //
  447. // g_missile.c
  448. //
  449. void G_RunMissile( gentity_t *ent );
  450.  
  451. gentity_t *fire_blaster (gentity_t *self, vec3_t start, vec3_t aimdir);
  452. gentity_t *fire_plasma (gentity_t *self, vec3_t start, vec3_t aimdir);
  453. gentity_t *fire_grenade (gentity_t *self, vec3_t start, vec3_t aimdir);
  454. gentity_t *fire_rocket (gentity_t *self, vec3_t start, vec3_t dir);
  455. gentity_t *fire_bfg (gentity_t *self, vec3_t start, vec3_t dir);
  456. gentity_t *fire_grapple (gentity_t *self, vec3_t start, vec3_t dir);
  457.  
  458.  
  459. //
  460. // g_mover.c
  461. //
  462. void G_RunMover( gentity_t *ent );
  463. void Touch_DoorTrigger( gentity_t *ent, gentity_t *other, trace_t *trace );
  464.  
  465. //
  466. // g_trigger.c
  467. //
  468. void trigger_teleporter_touch (gentity_t *self, gentity_t *other, trace_t *trace );
  469.  
  470.  
  471. //
  472. // g_misc.c
  473. //
  474. void TeleportPlayer( gentity_t *player, vec3_t origin, vec3_t angles );
  475.  
  476.  
  477. //
  478. // g_weapon.c
  479. //
  480. qboolean LogAccuracyHit( gentity_t *target, gentity_t *attacker );
  481. void CalcMuzzlePoint ( gentity_t *ent, vec3_t forward, vec3_t right, vec3_t up, vec3_t muzzlePoint );
  482. void SnapVectorTowards( vec3_t v, vec3_t to );
  483. qboolean CheckGauntletAttack( gentity_t *ent );
  484. void Weapon_HookFree (gentity_t *ent);
  485. void Weapon_HookThink (gentity_t *ent);
  486.  
  487.  
  488. //
  489. // g_client.c
  490. //
  491. team_t TeamCount( int ignoreClientNum, int team );
  492. team_t PickTeam( int ignoreClientNum );
  493. void SetClientViewAngle( gentity_t *ent, vec3_t angle );
  494. gentity_t *SelectSpawnPoint ( vec3_t avoidPoint, vec3_t origin, vec3_t angles );
  495. void respawn (gentity_t *ent);
  496. void BeginIntermission (void);
  497. void InitClientPersistant (gclient_t *client);
  498. void InitClientResp (gclient_t *client);
  499. void InitBodyQue (void);
  500. void ClientSpawn( gentity_t *ent );
  501. void player_die (gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod);
  502. void AddScore( gentity_t *ent, int score );
  503. void CalculateRanks( void );
  504. qboolean SpotWouldTelefrag( gentity_t *spot );
  505.  
  506. //
  507. // g_svcmds.c
  508. //
  509. qboolean    ConsoleCommand( void );
  510. void G_ProcessIPBans(void);
  511. qboolean G_FilterPacket (char *from);
  512.  
  513. //
  514. // g_weapon.c
  515. //
  516. void FireWeapon( gentity_t *ent );
  517.  
  518. //
  519. // p_hud.c
  520. //
  521. void MoveClientToIntermission (gentity_t *client);
  522. void G_SetStats (gentity_t *ent);
  523. void DeathmatchScoreboardMessage (gentity_t *client);
  524.  
  525. //
  526. // g_cmds.c
  527. //
  528. static void G_SayTo( gentity_t *ent, gentity_t *other, int mode, int color, const char *name, const char *message );
  529.  
  530. //
  531. // g_pweapon.c
  532. //
  533.  
  534.  
  535. //
  536. // g_main.c
  537. //
  538. void FindIntermissionPoint( void );
  539. void G_RunThink (gentity_t *ent);
  540. void QDECL G_LogPrintf( const char *fmt, ... );
  541. void SendScoreboardMessageToAllClients( void );
  542. void QDECL G_Printf( const char *fmt, ... );
  543. void QDECL G_Error( const char *fmt, ... );
  544.  
  545. //
  546. // g_client.c
  547. //
  548. char *ClientConnect( int clientNum, qboolean firstTime, qboolean isBot );
  549. void ClientUserinfoChanged( int clientNum );
  550. void ClientDisconnect( int clientNum );
  551. void ClientBegin( int clientNum );
  552. void ClientCommand( int clientNum );
  553.  
  554. //
  555. // g_active.c
  556. //
  557. void ClientThink( int clientNum );
  558. void ClientEndFrame( gentity_t *ent );
  559. void G_RunClient( gentity_t *ent );
  560.  
  561. //
  562. // g_team.c
  563. //
  564. qboolean OnSameTeam( gentity_t *ent1, gentity_t *ent2 );
  565. void Team_CheckDroppedItem( gentity_t *dropped );
  566.  
  567.  
  568. //
  569. // g_mem.c
  570. //
  571. void *G_Alloc( int size );
  572. void G_InitMemory( void );
  573. void Svcmd_GameMem_f( void );
  574.  
  575. //
  576. // g_session.c
  577. //
  578. void G_ReadSessionData( gclient_t *client );
  579. void G_InitSessionData( gclient_t *client, char *userinfo );
  580.  
  581. void G_InitWorldSession( void );
  582. void G_WriteSessionData( void );
  583.  
  584. //
  585. // g_arenas.c
  586. //
  587. void UpdateTournamentInfo( void );
  588. void SpawnModelsOnVictoryPads( void );
  589. void Svcmd_AbortPodium_f( void );
  590.  
  591. //
  592. // g_bot.c
  593. //
  594. void G_InitBots( qboolean restart );
  595. char *G_GetBotInfoByNumber( int num );
  596. char *G_GetBotInfoByName( const char *name );
  597. void G_CheckBotSpawn( void );
  598. void G_QueueBotBegin( int clientNum );
  599. qboolean G_BotConnect( int clientNum, qboolean restart );
  600. void Svcmd_AddBot_f( void );
  601. void Svcmd_BotList_f( void );
  602. void BotInterbreedEndMatch( void );
  603.  
  604. // ai_main.c
  605.  
  606. //some maxs
  607. #define MAX_NETNAME                36
  608. #define MAX_FILEPATH            144
  609.  
  610. //bot settings
  611. typedef struct bot_settings_s
  612. {
  613.     char characterfile[MAX_FILEPATH];
  614.     int skill;
  615.     char team[MAX_FILEPATH];
  616. } bot_settings_t;
  617.  
  618. int BotAISetup( int restart );
  619. int BotAIShutdown( int restart );
  620. int BotAILoadMap( int restart );
  621. int BotAISetupClient( int client, bot_settings_t *settings );
  622. int BotAIShutdownClient( int client );
  623. int BotAIStartFrame( int time );
  624.  
  625.  
  626. #include "g_team.h" // teamplay specific stuff
  627.  
  628.  
  629. extern    level_locals_t    level;
  630. extern    gentity_t        g_entities[MAX_GENTITIES];
  631.  
  632. #define    FOFS(x) ((int)&(((gentity_t *)0)->x))
  633.  
  634. extern    vmCvar_t    g_gametype;
  635. extern    vmCvar_t    g_dedicated;
  636. extern    vmCvar_t    g_cheats;
  637. extern    vmCvar_t    g_maxclients;            // allow this many total, including spectators
  638. extern    vmCvar_t    g_maxGameClients;        // allow this many active
  639. extern    vmCvar_t    g_restarted;
  640.  
  641. extern    vmCvar_t    g_dmflags;
  642. extern    vmCvar_t    g_fraglimit;
  643. extern    vmCvar_t    g_timelimit;
  644. extern    vmCvar_t    g_capturelimit;
  645. extern    vmCvar_t    g_friendlyFire;
  646. extern    vmCvar_t    g_password;
  647. extern    vmCvar_t    g_needpass;
  648. extern    vmCvar_t    g_gravity;
  649. extern    vmCvar_t    g_speed;
  650. extern    vmCvar_t    g_knockback;
  651. extern    vmCvar_t    g_quadfactor;
  652. extern    vmCvar_t    g_forcerespawn;
  653. extern    vmCvar_t    g_inactivity;
  654. extern    vmCvar_t    g_debugMove;
  655. extern    vmCvar_t    g_debugAlloc;
  656. extern    vmCvar_t    g_debugDamage;
  657. extern    vmCvar_t    g_weaponRespawn;
  658. extern    vmCvar_t    g_syncronousClients;
  659. extern    vmCvar_t    g_motd;
  660. extern    vmCvar_t    g_warmup;
  661. extern    vmCvar_t    g_doWarmup;
  662. extern    vmCvar_t    g_blood;
  663. extern    vmCvar_t    g_allowVote;
  664. extern    vmCvar_t    g_teamAutoJoin;
  665. extern    vmCvar_t    g_teamForceBalance;
  666. extern    vmCvar_t    g_banIPs;
  667. extern    vmCvar_t    g_filterBan;
  668.  
  669. void    trap_Printf( const char *fmt );
  670. void    trap_Error( const char *fmt );
  671. int        trap_Milliseconds( void );
  672. int        trap_Argc( void );
  673. void    trap_Argv( int n, char *buffer, int bufferLength );
  674. void    trap_Args( char *buffer, int bufferLength );
  675. int        trap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode );
  676. void    trap_FS_Read( void *buffer, int len, fileHandle_t f );
  677. void    trap_FS_Write( const void *buffer, int len, fileHandle_t f );
  678. void    trap_FS_FCloseFile( fileHandle_t f );
  679. int        trap_FS_GetFileList( const char *path, const char *extension, char *listbuf, int bufsize );
  680. void    trap_SendConsoleCommand( int exec_when, const char *text );
  681. void    trap_Cvar_Register( vmCvar_t *cvar, const char *var_name, const char *value, int flags );
  682. void    trap_Cvar_Update( vmCvar_t *cvar );
  683. void    trap_Cvar_Set( const char *var_name, const char *value );
  684. int        trap_Cvar_VariableIntegerValue( const char *var_name );
  685. void    trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize );
  686. void    trap_LocateGameData( gentity_t *gEnts, int numGEntities, int sizeofGEntity_t, playerState_t *gameClients, int sizeofGameClient );
  687. void    trap_DropClient( int clientNum, const char *reason );
  688. void    trap_SendServerCommand( int clientNum, const char *text );
  689. void    trap_SetConfigstring( int num, const char *string );
  690. void    trap_GetConfigstring( int num, char *buffer, int bufferSize );
  691. void    trap_GetUserinfo( int num, char *buffer, int bufferSize );
  692. void    trap_SetUserinfo( int num, const char *buffer );
  693. void    trap_GetServerinfo( char *buffer, int bufferSize );
  694. void    trap_SetBrushModel( gentity_t *ent, const char *name );
  695. void    trap_Trace( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentmask );
  696. int        trap_PointContents( const vec3_t point, int passEntityNum );
  697. qboolean trap_InPVS( const vec3_t p1, const vec3_t p2 );
  698. qboolean trap_InPVSIgnorePortals( const vec3_t p1, const vec3_t p2 );
  699. void    trap_AdjustAreaPortalState( gentity_t *ent, qboolean open );
  700. qboolean trap_AreasConnected( int area1, int area2 );
  701. void    trap_LinkEntity( gentity_t *ent );
  702. void    trap_UnlinkEntity( gentity_t *ent );
  703. int        trap_EntitiesInBox( const vec3_t mins, const vec3_t maxs, int *entityList, int maxcount );
  704. qboolean trap_EntityContact( const vec3_t mins, const vec3_t maxs, const gentity_t *ent );
  705. int        trap_BotAllocateClient( void );
  706. void    trap_BotFreeClient( int clientNum );
  707. void    trap_GetUsercmd( int clientNum, usercmd_t *cmd );
  708. qboolean    trap_GetEntityToken( char *buffer, int bufferSize );
  709.  
  710. int        trap_DebugPolygonCreate(int color, int numPoints, vec3_t *points);
  711. void    trap_DebugPolygonDelete(int id);
  712.  
  713. int        trap_BotLibSetup( void );
  714. int        trap_BotLibShutdown( void );
  715. int        trap_BotLibVarSet(char *var_name, char *value);
  716. int        trap_BotLibVarGet(char *var_name, char *value, int size);
  717. int        trap_BotLibDefine(char *string);
  718. int        trap_BotLibStartFrame(float time);
  719. int        trap_BotLibLoadMap(const char *mapname);
  720. int        trap_BotLibUpdateEntity(int ent, void /* struct bot_updateentity_s */ *bue);
  721. int        trap_BotLibTest(int parm0, char *parm1, vec3_t parm2, vec3_t parm3);
  722.  
  723. int        trap_BotGetSnapshotEntity( int clientNum, int sequence );
  724. int        trap_BotGetConsoleMessage(int clientNum, char *message, int size);
  725. void    trap_BotUserCommand(int client, usercmd_t *ucmd);
  726.  
  727. void        trap_AAS_EntityInfo(int entnum, void /* struct aas_entityinfo_s */ *info);
  728.  
  729. int            trap_AAS_Initialized(void);
  730. void        trap_AAS_PresenceTypeBoundingBox(int presencetype, vec3_t mins, vec3_t maxs);
  731. float        trap_AAS_Time(void);
  732.  
  733. int            trap_AAS_PointAreaNum(vec3_t point);
  734. int            trap_AAS_TraceAreas(vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas);
  735.  
  736. int            trap_AAS_PointContents(vec3_t point);
  737. int            trap_AAS_NextBSPEntity(int ent);
  738. int            trap_AAS_ValueForBSPEpairKey(int ent, char *key, char *value, int size);
  739. int            trap_AAS_VectorForBSPEpairKey(int ent, char *key, vec3_t v);
  740. int            trap_AAS_FloatForBSPEpairKey(int ent, char *key, float *value);
  741. int            trap_AAS_IntForBSPEpairKey(int ent, char *key, int *value);
  742.  
  743. int            trap_AAS_AreaReachability(int areanum);
  744.  
  745. int            trap_AAS_AreaTravelTimeToGoalArea(int areanum, vec3_t origin, int goalareanum, int travelflags);
  746.  
  747. int            trap_AAS_Swimming(vec3_t origin);
  748. int            trap_AAS_PredictClientMovement(void /* aas_clientmove_s */ *move, int entnum, vec3_t origin, int presencetype, int onground, vec3_t velocity, vec3_t cmdmove, int cmdframes, int maxframes, float frametime, int stopevent, int stopareanum, int visualize);
  749.  
  750.  
  751. void    trap_EA_Say(int client, char *str);
  752. void    trap_EA_SayTeam(int client, char *str);
  753. void    trap_EA_UseItem(int client, char *it);
  754. void    trap_EA_DropItem(int client, char *it);
  755. void    trap_EA_UseInv(int client, char *inv);
  756. void    trap_EA_DropInv(int client, char *inv);
  757. void    trap_EA_Gesture(int client);
  758. void    trap_EA_Command(int client, char *command);
  759.  
  760. void    trap_EA_SelectWeapon(int client, int weapon);
  761. void    trap_EA_Talk(int client);
  762. void    trap_EA_Attack(int client);
  763. void    trap_EA_Use(int client);
  764. void    trap_EA_Respawn(int client);
  765. void    trap_EA_Jump(int client);
  766. void    trap_EA_DelayedJump(int client);
  767. void    trap_EA_Crouch(int client);
  768. void    trap_EA_MoveUp(int client);
  769. void    trap_EA_MoveDown(int client);
  770. void    trap_EA_MoveForward(int client);
  771. void    trap_EA_MoveBack(int client);
  772. void    trap_EA_MoveLeft(int client);
  773. void    trap_EA_MoveRight(int client);
  774. void    trap_EA_Move(int client, vec3_t dir, float speed);
  775. void    trap_EA_View(int client, vec3_t viewangles);
  776.  
  777. void    trap_EA_EndRegular(int client, float thinktime);
  778. void    trap_EA_GetInput(int client, float thinktime, void /* struct bot_input_s */ *input);
  779. void    trap_EA_ResetInput(int client);
  780.  
  781.  
  782. int        trap_BotLoadCharacter(char *charfile, int skill);
  783. void    trap_BotFreeCharacter(int character);
  784. float    trap_Characteristic_Float(int character, int index);
  785. float    trap_Characteristic_BFloat(int character, int index, float min, float max);
  786. int        trap_Characteristic_Integer(int character, int index);
  787. int        trap_Characteristic_BInteger(int character, int index, int min, int max);
  788. void    trap_Characteristic_String(int character, int index, char *buf, int size);
  789.  
  790. int        trap_BotAllocChatState(void);
  791. void    trap_BotFreeChatState(int handle);
  792. void    trap_BotQueueConsoleMessage(int chatstate, int type, char *message);
  793. void    trap_BotRemoveConsoleMessage(int chatstate, int handle);
  794. int        trap_BotNextConsoleMessage(int chatstate, void /* struct bot_consolemessage_s */ *cm);
  795. int        trap_BotNumConsoleMessages(int chatstate);
  796. void    trap_BotInitialChat(int chatstate, char *type, int mcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7 );
  797. int        trap_BotNumInitialChats(int chatstate, char *type);
  798. int        trap_BotReplyChat(int chatstate, char *message, int mcontext, int vcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7 );
  799. int        trap_BotChatLength(int chatstate);
  800. void    trap_BotEnterChat(int chatstate, int client, int sendto);
  801. void    trap_BotGetChatMessage(int chatstate, char *buf, int size);
  802. int        trap_StringContains(char *str1, char *str2, int casesensitive);
  803. int        trap_BotFindMatch(char *str, void /* struct bot_match_s */ *match, unsigned long int context);
  804. void    trap_BotMatchVariable(void /* struct bot_match_s */ *match, int variable, char *buf, int size);
  805. void    trap_UnifyWhiteSpaces(char *string);
  806. void    trap_BotReplaceSynonyms(char *string, unsigned long int context);
  807. int        trap_BotLoadChatFile(int chatstate, char *chatfile, char *chatname);
  808. void    trap_BotSetChatGender(int chatstate, int gender);
  809. void    trap_BotSetChatName(int chatstate, char *name);
  810. void    trap_BotResetGoalState(int goalstate);
  811. void    trap_BotRemoveFromAvoidGoals(int goalstate, int number);
  812. void    trap_BotResetAvoidGoals(int goalstate);
  813. void    trap_BotPushGoal(int goalstate, void /* struct bot_goal_s */ *goal);
  814. void    trap_BotPopGoal(int goalstate);
  815. void    trap_BotEmptyGoalStack(int goalstate);
  816. void    trap_BotDumpAvoidGoals(int goalstate);
  817. void    trap_BotDumpGoalStack(int goalstate);
  818. void    trap_BotGoalName(int number, char *name, int size);
  819. int        trap_BotGetTopGoal(int goalstate, void /* struct bot_goal_s */ *goal);
  820. int        trap_BotGetSecondGoal(int goalstate, void /* struct bot_goal_s */ *goal);
  821. int        trap_BotChooseLTGItem(int goalstate, vec3_t origin, int *inventory, int travelflags);
  822. int        trap_BotChooseNBGItem(int goalstate, vec3_t origin, int *inventory, int travelflags, void /* struct bot_goal_s */ *ltg, float maxtime);
  823. int        trap_BotTouchingGoal(vec3_t origin, void /* struct bot_goal_s */ *goal);
  824. int        trap_BotItemGoalInVisButNotVisible(int viewer, vec3_t eye, vec3_t viewangles, void /* struct bot_goal_s */ *goal);
  825. int        trap_BotGetNextCampSpotGoal(int num, void /* struct bot_goal_s */ *goal);
  826. int        trap_BotGetMapLocationGoal(char *name, void /* struct bot_goal_s */ *goal);
  827. int        trap_BotGetLevelItemGoal(int index, char *classname, void /* struct bot_goal_s */ *goal);
  828. float    trap_BotAvoidGoalTime(int goalstate, int number);
  829. void    trap_BotInitLevelItems(void);
  830. void    trap_BotUpdateEntityItems(void);
  831. int        trap_BotLoadItemWeights(int goalstate, char *filename);
  832. void    trap_BotFreeItemWeights(int goalstate);
  833. void    trap_BotInterbreedGoalFuzzyLogic(int parent1, int parent2, int child);
  834. void    trap_BotSaveGoalFuzzyLogic(int goalstate, char *filename);
  835. void    trap_BotMutateGoalFuzzyLogic(int goalstate, float range);
  836. int        trap_BotAllocGoalState(int state);
  837. void    trap_BotFreeGoalState(int handle);
  838.  
  839. void    trap_BotResetMoveState(int movestate);
  840. void    trap_BotMoveToGoal(void /* struct bot_moveresult_s */ *result, int movestate, void /* struct bot_goal_s */ *goal, int travelflags);
  841. int        trap_BotMoveInDirection(int movestate, vec3_t dir, float speed, int type);
  842. void    trap_BotResetAvoidReach(int movestate);
  843. void    trap_BotResetLastAvoidReach(int movestate);
  844. int        trap_BotReachabilityArea(vec3_t origin, int testground);
  845. int        trap_BotMovementViewTarget(int movestate, void /* struct bot_goal_s */ *goal, int travelflags, float lookahead, vec3_t target);
  846. int        trap_BotPredictVisiblePosition(vec3_t origin, int areanum, void /* struct bot_goal_s */ *goal, int travelflags, vec3_t target);
  847. int        trap_BotAllocMoveState(void);
  848. void    trap_BotFreeMoveState(int handle);
  849. void    trap_BotInitMoveState(int handle, void /* struct bot_initmove_s */ *initmove);
  850.  
  851. int        trap_BotChooseBestFightWeapon(int weaponstate, int *inventory);
  852. void    trap_BotGetWeaponInfo(int weaponstate, int weapon, void /* struct weaponinfo_s */ *weaponinfo);
  853. int        trap_BotLoadWeaponWeights(int weaponstate, char *filename);
  854. int        trap_BotAllocWeaponState(void);
  855. void    trap_BotFreeWeaponState(int weaponstate);
  856. void    trap_BotResetWeaponState(int weaponstate);
  857.  
  858. int        trap_GeneticParentsAndChildSelection(int numranks, float *ranks, int *parent1, int *parent2, int *child);
  859.